<!--
 * @Author: yuanming
 * @Date: 2024-06-30 08:01:12
 * @LastEditors: yuanming
 * @LastEditTime: 2024-08-26 16:34:07
 * @Description: fileDescription
-->
<template>
    <div class="countTo">
        <CountTo :start-val="start" :end-val="end" :duration="dura" />
    </div>
</template>
<script setup>
import { watch } from 'vue'

const start = ref(0)
const end = ref(0)
const dura = ref(3)

const propsData = defineProps({
    startVal: {
        type: Number,
        default: 0,
    },
    endVal: {
        type: Number,
        default: 0,
    },
    duration: {
        type: Number,
        default: 3,
    },
})
watch(() => propsData.endVal, (newVal, oldVal) => {
    start.value = oldVal || 0
    end.value = newVal
}, { immediate: true, deep: false })
watch(() => propsData.duration, (newVal) => {
    dura.value = newVal
}, { immediate: true, deep: false })
</script>